package reflect;

import java.lang.reflect.Method;

/**
 *
 */
public class ReflectDemo6 {
    public static void main(String[] args) throws Exception {
        Person  p =new Person();
       // p.hehe();
        Class cls=Class.forName("reflect.Person");
        Object o=cls.newInstance();//new Person()

        Method method= cls.getDeclaredMethod("hehe");
        method.setAccessible(true);//强行设置访问权限
        method.invoke(o);//p.hehe()

    }
}
